<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="./../../template/tagedu.xhtml">

    <ui:define name="title">
        <title><h:outputText value="Relatórios - TAG"/></title>
    </ui:define>

    <ui:define name="content">
        <h:outputText styleClass="enrollmentName" value="Relatórios"/>
        <h:form id="wahForm">
            <div class="input-list">
                <h:outputLabel class="label" value="Relatório: "/>
                <p:selectOneMenu id ="report" value ="#{reportsBean.selectedReport}"> 
                    <f:selectItem value="#{null}" itemLabel="Selecione o Relatório:"/>
                    <f:selectItems value="#{reportsBean.reportList}" var="r" itemLabel="#{r.toString()}" itemValue="#{r}" />
                    <p:ajax process="@this" update=":options"/>
                </p:selectOneMenu>
            </div>
        </h:form>
        <br/> <br/>
        <h:panelGroup id="options">
            <h:form id="StudentForm">
                <p:panel id ="StudentsPerClass" rendered="#{reportsBean.selectedReport == 'STUDENTS_PER_CLASS'}">
                    <div class="input-list">
                        <h:outputLabel class="label" value="Ano: "/>
                        <p:spinner value="#{reportsBean.year}" min="#{reportsBean.actualYear-1}" max="#{reportsBean.actualYear}"  size="4">
                            <f:attribute name="minimo" value="#{(reportsBean.actualYear-1).toString()}"/>
                            <f:attribute name="maximo" value="#{(reportsBean.actualYear).toString()}"/>
                            <p:ajax process="@this" update="unity"/>
                        </p:spinner>
                    </div>
                    <div class="input-list">
                        <h:outputLabel class="label" value="Turma: " for="unity"/>
                        <p:selectOneMenu id="unity" value="#{reportsBean.unity}" converter="unityC" >
                            <f:selectItem value="#{null}" itemLabel="Selecione uma unidade:"/>
                            <f:selectItems value="#{reportsBean.unityList}" var="u" itemLabel="#{u.name}" itemValue="#{u}" />   
                        </p:selectOneMenu>
                    </div>
                    <p:commandButton action="#{reportsBean.report()}"
                                     value="Gerar Relatório" ajax="false"
                                     onclick="this.form.target='_blank'"/>
                </p:panel>
            </h:form>
            <h:form id="DeclarationForm">
                <p:panel id ="Declaration" rendered="#{reportsBean.selectedReport == 'DECLARATION'}">
                    
                    <p:commandButton action="#{reportsBean.report()}"  value="Gerar Relatório" ajax="false"
                                     onclick="this.form.target='_blank'"/>
                </p:panel>
            </h:form>
        </h:panelGroup>
    </ui:define>
</ui:composition>